/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Jhon
 */
@Entity
@Table(name = "banktx", catalog = "taller", schema = "")
@NamedQueries({
    @NamedQuery(name = "Banktx.findAll", query = "SELECT b FROM Banktx b"),
    @NamedQuery(name = "Banktx.findByIdBankTx", query = "SELECT b FROM Banktx b WHERE b.banktxPK.idBankTx = :idBankTx"),
    @NamedQuery(name = "Banktx.findByTimestamp", query = "SELECT b FROM Banktx b WHERE b.timestamp = :timestamp"),
    @NamedQuery(name = "Banktx.findByValue", query = "SELECT b FROM Banktx b WHERE b.value = :value"),
    @NamedQuery(name = "Banktx.findByAccountUseridUser", query = "SELECT b FROM Banktx b WHERE b.banktxPK.accountUseridUser = :accountUseridUser"),
    @NamedQuery(name = "Banktx.findByTxTypeidTxType", query = "SELECT b FROM Banktx b WHERE b.banktxPK.txTypeidTxType = :txTypeidTxType"),
    @NamedQuery(name = "Banktx.findByAccountidAccount", query = "SELECT b FROM Banktx b WHERE b.banktxPK.accountidAccount = :accountidAccount")})
public class Banktx implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected BanktxPK banktxPK;
    @Basic(optional = false)
    @Column(name = "timestamp", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date timestamp;
    @Basic(optional = false)
    @Column(name = "value", nullable = false)
    private double value;
    @JoinColumn(name = "TxType_idTxType", referencedColumnName = "idTxType", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Txtype txtype;
    @JoinColumns({
        @JoinColumn(name = "Account_idAccount", referencedColumnName = "idAccount", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "Account_User_idUser", referencedColumnName = "User_idUser", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Account account;

    public Banktx() {
    }

    public Banktx(BanktxPK banktxPK) {
        this.banktxPK = banktxPK;
    }

    public Banktx(BanktxPK banktxPK, Date timestamp, double value) {
        this.banktxPK = banktxPK;
        this.timestamp = timestamp;
        this.value = value;
    }

    public Banktx(int idBankTx, int accountUseridUser, int txTypeidTxType, int accountidAccount) {
        this.banktxPK = new BanktxPK(idBankTx, accountUseridUser, txTypeidTxType, accountidAccount);
    }

    public BanktxPK getBanktxPK() {
        return banktxPK;
    }

    public void setBanktxPK(BanktxPK banktxPK) {
        this.banktxPK = banktxPK;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    public Txtype getTxtype() {
        return txtype;
    }

    public void setTxtype(Txtype txtype) {
        this.txtype = txtype;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (banktxPK != null ? banktxPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Banktx)) {
            return false;
        }
        Banktx other = (Banktx) object;
        if ((this.banktxPK == null && other.banktxPK != null) || (this.banktxPK != null && !this.banktxPK.equals(other.banktxPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Banktx[banktxPK=" + banktxPK + "]";
    }

}
